/* GUI CONVERTED from rwworle.p (converter v1.75) Sat Aug 12 23:18:36 2000 */
/* rwworle.p - SCHEDULE WORK ORDER OPERATIONS                           */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/*V8:ConvertMode=Maintenance                                            */
/*H1H4*/ /*V8:WebEnabled=No                                             */
/* Revision: 8.6E    Modified: 08/05/98      BY: *H1H4* Dana Tunstall   */
/* Revision: 9.1     Modified: 08/12/00      BY: *N0KP* myb             */


         {mfdeclre.i}


         define shared temp-table temp-wo_mstr no-undo like wo_mstr
                use-index wo_nbr.
         define shared temp-table temp-wr_route no-undo like wr_route
                use-index wr_lot.

         define shared variable wo_recno as recid.
         define variable last_due as date no-undo.
         define variable last_op as integer no-undo.

         find temp-wo_mstr no-lock
            where recid(temp-wo_mstr) = wo_recno no-error.

         if not available temp-wo_mstr then leave.

         last_op = 999999.
         for each temp-wr_route no-lock where wr_lot = wo_lot
            by wr_lot descending by wr_op descending:
            if wr_status = "C" then leave.
            last_op = wr_op.
         end.

         if wo_due_date <> ? then do:

            last_due = wo_due_date.

            /* SCHEDULE BACKWARDS FROM WORK ORDER DUE DATE */
            {gprun.i ""woworle1.p""
               "(input wo_lot,
                 input wo_site,
                 input last_op,
                 input-output last_due)"}
/*GUI*/ if global-beam-me-up then undo, leave.


            if wo_rel_date = ? then wo_rel_date = last_due.
         end.
         else do:

            last_due = wo_rel_date.

            /* SCHEDULE FORWARDS FROM WORK ORDER RELEASE DATE */
            {gprun.i ""woworle2.p""
               "(input wo_lot,
                 input wo_site,
                 input last_op,
                 input-output last_due)"}
/*GUI*/ if global-beam-me-up then undo, leave.


            if wo_due_date = ? then wo_due_date = last_due.
         end.
